/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package beans;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author Ruba
 */
public class ThreadActionForm extends org.apache.struts.action.ActionForm {
    
    private String threadTitle ;
    private String threadBody ;
    private int id ;  // used for forumid in add thread and for threadid in edit thread
    private String threadDescription;
    /**
     * @return
     */
    /**
     *
     */
    public ThreadActionForm() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        if (getThreadBody() == null || getThreadTitle() == null) {
            errors.add("name", new ActionMessage("error.name.required"));
            // TODO: add 'error.name.required' key to your resources
        }
        return errors;
    }

    public void reset(ActionMapping mapping, HttpServletRequest request){
        super.reset(mapping,request);
        setThreadBody("");
        setThreadTitle("");
    }

    /**
     * @return the threadTitle
     */
    public String getThreadTitle() {
        return threadTitle;
    }

    /**
     * @param threadTitle the threadTitle to set
     */
    public void setThreadTitle(String threadTitle) {
        this.threadTitle = threadTitle;
        System.out.println("thread title @ bean"+threadTitle);
    }

    /**
     * @return the threadBody
     */
    public String getThreadBody() {
        return threadBody;
    }

    /**
     * @param threadBody the threadBody to set
     */
    public void setThreadBody(String threadBody) {
        this.threadBody = threadBody;
        System.out.println("thread body @ bean"+threadBody);
    }

    /**
     * @return the id
     */
    public int getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(int id) {
        this.id = id;
        System.out.println("id@ bean"+id);
    }

    public String getThreadDescription() {
        return threadDescription;
    }

    public void setThreadDescription(String threadDescription) {
        this.threadDescription = threadDescription;
    }


}
